package com.lx.ngsl.exam.quest.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.lx.ngsl.exam.quest.entity.ChoiceEntity;

public interface ChoiceRepository extends JpaRepository<ChoiceEntity, String> {

	
	List<ChoiceEntity> findByQuestId(String questId);
	
	@Modifying
	@Query(value="update db_answer t set t.status = '0' where t.quest_id = :questId ",nativeQuery=true)
	int deleteByQuestId(@Param("questId") String questId);
	/*
	 * 查询选择题的正确选项
	 */
	@Query(value="select t.inx from ChoiceEntity t where t.questId = :questId and t.isTrue = '1' order by t.inx asc ")
	List<String> getCorrectChoice(@Param("questId") String questId);
	/*
	 * 查询选项
	 */
	@Query(value="from ChoiceEntity t where t.questId = :questId  ")
	List<ChoiceEntity> getChoices(@Param("questId")String questId);
}
